#pragma once

#include <CVector.h>
#include <list>
#include <cmath>
using namespace std;
//typedef int Uint32 ;

/*
 * Class CParticle - contains all information about a single particle
 *   Position, Velocity, Acceleration
 *   Acceleration is calculated for each timestep
 *   RK4 / Euler time integration
 */

class CParticle
{
 public:

  CVector P,V,A,A_old;
  double Mass, Charge, dist; 
  double Radius; // Used for TreeCode. Name should be changed.
  float flag;
  
  CParticle *next, *prev;
  CParticle *nn, *pp;


  CParticle();
  void Move(double deltat);
  void LeapFrog(double deltat);

  void RungeKuttaIntegrator(float DT, double scale);
  // used internally for RK4 evaluation
  void RK4Eval(float DT, CVector d[2], CVector* output);

  void KillFromList() {
    if (next) 
      next->prev = prev;
  
    if (prev)
      prev->next = next;

    next = 0;
    prev = 0;

  }

 void KillFromList2() {
    if (nn) 
      nn->pp = pp;
  
    if (pp)
      pp->nn = nn;

    pp = 0;
    nn = 0;

  }

  CVector Mv();
  double Ekin();

};
